home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: How to tell if a file exists in C
- Date: Mon, 19 Feb 96 19:54:33 GMT
- Organization: none
- Message-ID: <824759673snz@genesis.demon.co.uk>
- References: <4eqkj6$ipo@charm.magnus.acs.ohio-state.edu> <4eqn9q$dr1@sparcserver.lrz-muenchen.de> <3121db3e.43150046@nntp.ix.netcom.com> <4ftpnk$i74@cafu.fl.net.au> <824493561snz@genesis.demon.co.uk> <4g8132$mg9@cafu.fl.net.au>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4g8132$mg9@cafu.fl.net.au> als@fl.net.au "Andrew Snow" writes:
-
- >>access() is a specialised function under Unix/POSIX to test permissions
- >>against the real user/group ID's. If you don't want to do that specifically
- >>you should never use access() (and why on other systems you should avoid it
- >>where portability is concerned). stat() is the way to go in that case.
- >
- >Specialised? well its a part of every single DOS compiler I've ever
- >seen.
-
- Why is it that so may DOS progarmmers seem to have this tunnel vision?
- Believe it or not there are systems besides DOS out there. My point remains
- that if you want to code for portability you avoid access() (as I noted you
- can use stat() instead in most cases). Where systems define an access()
- function it is typically based on the Unix/POSIX version (and that includes
- DOS). I quote from Lewine:
-
- "access() uses the real UID, not the effective UID. It is not a general
- utility for finding out 'Can I do this?' before doing a call. It is used by
- SETUID programs to check their actions".
-
- My point is that porting code that uses access() to different platforms may
- not give the expected results because you are not using it for the purpose
- for which it was intended. That's why it is best to use an alternative.
-
- >>However neither of these are as portable as fopen() since that is defined by
- >>the C language.
- >
- >True, however I was only offering access() as a viable alternative.
-
- So long as you understand its limitations.
-
- >>>If you want to see if the file is readable as well as exists,
- >
- >>Can a file be readable yet not exist?
- >
- >No, but did you really want me to spell it out? You ought to have
- >been able to figure it out. Sorry if you couldn't.
-
- I was just wondering if you'd figured it out.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-